using Framework.DataTable;
using System.Collections.Generic;
public partial class LangTable : DataTableLoader<LangData>
{
    public override string GetTableName() { return "Lang"; }
    protected override LangData CreateItem()
    {
        return new Lang1();
    }
    public LangTable()
    {
        _branchs = new List<string>() { "ch", "en" };
    }
#if true
    private Dictionary<string, int> _keyToIndex;
    protected override void BuildIndex()
    {
        base.BuildIndex();
        if (_keyToIndex == null)
        {
            _keyToIndex = new Dictionary<string, int>(ItemCount);
        }
        else
        {
            _keyToIndex.Clear();
        }
        var len = DataList.Count;
        for (int i = 0; i < len; i++)
        {
            var item = DataList[i];
            if (item == null)
            {
                break;
            }
            if (_keyToIndex.ContainsKey(item.Id))
            {
                UnityEngine.Debug.LogErrorFormat("{0} 存在相同的索引 {1}", FileName, item.Id);
                continue;
            }
            _keyToIndex.Add(item.Id, i);
        }
    }
    public LangData Get(string key)
    {
        if (_keyToIndex != null && _keyToIndex.TryGetValue(key, out int index))
        {
            return GetItem(index);
        }
        return null;
    }
#endif
}
public partial class LangData
{
    public string Id { get; protected set; }
    public string Text { get; protected set; }
}
public partial class LangData : IDataTable
{
    public virtual void Decode(Framework.ByteArray buffer)
    {
        Id = buffer.ReadString();
        Text = buffer.ReadString();
    }
}
#if UNITY_EDITOR
public partial class LangData : IDataTable
{
	public void Parse(string[] values)
	{
        Id = values[0];
        Text = values[1];
	}
    public void Encode(Framework.ByteArray buffer)
    {
        buffer.Write(Id);
        buffer.Write(Text);
    }
}
#endif